package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.domain.MemberProject;
import com.zzyl.nursing.service.MemberProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value ="/member/orders")
public class MemberProjectController extends BaseController {
    @Autowired
    private MemberProjectService memberProjectService;


    @SuppressWarnings("rawtypes")
    @GetMapping("/project/page")
    public TableDataInfo getProjectPage(MemberProject memberProject){
        startPage();
       List<MemberProject> list = memberProjectService.getProjectPage(memberProject);
        return getDataTable(list);
    }

    /**
     * 根据编号查询护理项目信息
     * @param id 护理项目ID
     * @return 护理项目信息
     */
    @GetMapping("/project/{id}")
    public AjaxResult getProjectById(@PathVariable("id") Long id) {
        MemberProject project = memberProjectService.getProjectById(id);
        if (project == null) {
            return error("护理项目不存在");
        }
        return success(project);
    }

}
